﻿import com.dmotiko.general.*
import com.dmotiko.util.Point
import mx.utils.Delegate

class SelectorInput
extends BaseClip {
	
	public static var SET_FOCUS:String = "selectorinput_setfocus";
	public static var KILL_FOCUS:String = "selectorinput_killfocus";
	
	/* FLA VARS */
	private var txt:TextField;
	private var mcPullDown:MovieClip;
	
	public function setText(text:String):Void {
		txt.text = text;
	}
	public function getText():String {
		return txt.text;
	}
	
	private function initClip() {
		var root:SelectorInput = this;
		txt.onSetFocus = function() {
			root.dispatchEvent( { type: SelectorInput.SET_FOCUS, target: root } );
		}
		txt.onKillFocus = function() {
			root.dispatchEvent( { type: SelectorInput.KILL_FOCUS, target: root } );
		}
		txt.onChanged = function() {
			root.dispatchEvent( { type: BaseClipEvent.CHANGED, target: root } );
		}
		
		if ( mcPullDown ) {
			if( mcPullDown instanceof BaseClip ){
				mcPullDown.onRelease = function() {
					this.dispatchEvent( { type: BaseClipEvent.CHANGED, target: this } );
				}
				mcPullDown.addEventListener( BaseClipEvent.CHANGED, Delegate.create( this, pulldown_release) );
			} else {
				mcPullDown.onRelease = function() {
					root.pulldown_release();
				}
			}
		}
	}
	
	private function pulldown_release( evnt ):Void {
		txt.text = "";
		dispatchEvent( { type: SelectorInput.SET_FOCUS, target: this } );
	}
		
	private function refreshData() {
		
	}
	
}